package IO.FileOutputStream;

/*
* 换行写：
* Windows:换行符：\r\n--->优化：\r或者\n，Java自动补全了
* Linux:换行符：\n
* Mac:换行符：\r
*
* 续写：续写开关：true: 续写,false: 不续写会覆盖
* */

import java.io.FileOutputStream;

public class Demo3 {
    public static void main(String[] args) throws Exception {
        //1、创建FileOutputStream对象
        FileOutputStream fos = new FileOutputStream("Day05/src/IO/FileOutputStream/outputTest.txt", true);

        //2、写入数据nihaonihaonihao66666
        String s1 = "nihaonihaonihao";
        String s2 = "666666";
        byte[] bytes = s1.getBytes();
        fos.write(bytes);

        //换行
        fos.write("\r\n".getBytes());

        fos.write(s2.getBytes());
        //3、关闭流
        fos.close();

        //续写==》 true: 续写,false: 不续写会覆盖--》主要是再创建对象后续写
        FileOutputStream fos1 = new FileOutputStream("Day05/src/IO/FileOutputStream/outputTest.txt", true);
        fos1.write("\r\n".getBytes());
        fos1.write("hello".getBytes());
        fos1.write("\r\n".getBytes());
        fos1.close();


    }
}
